// InterventionAnalysis.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "MLDataPoint.h"
#include "MLRegress_Linear.h"
#include "MLInterStreamCommander.h"
#include <stdlib.h>

using namespace mylablib;

int testAutoRegress()
{
	CMLDataSet dataSet;
	double dLast1 = 1,dLast2 = 2;
	double dCur;
	for (int i=0; i<10; i++)
	{
		dCur = dLast1 + dLast2 + 1;
		dataSet.Insert(ML_MakeDataPoint(dCur));
		dLast2 = dLast1;
		dLast1 = dCur;
	}

	std::vector<CMLDataPoint> coefficients;
	CMLRegress_Linear::AR_Regress(1, dataSet, 3, coefficients);
	for (int i=0; i<(int)coefficients.size(); i++)
	{
		std::wcout<<coefficients[i].ToWString() << L'\n';
	}
	return 0;
}

int testLinearRegress()
{
	std::vector<CMLDataSet> dataSets(4);
	for (int i=0; i<100; i++)
	{
		dataSets[0].Insert(ML_MakeDataPoint(i));
		dataSets[1].Insert(ML_MakeDataPoint(i*i));
		dataSets[2].Insert(ML_MakeDataPoint(1.0));
		dataSets[3].Insert(ML_MakeDataPoint(i*3+4*i*i+5));
	}

	std::vector<CMLDataPoint> coefficients;
	CMLRegress_Linear::MultiVariantRegress(1, dataSets, coefficients);
	for (int i=0; i<(int)coefficients.size(); i++)
	{
		std::wcout<<coefficients[i].ToWString() << L'\n';
	}
	return 0;
}

int testInterStreamAnalysis()
{
	CMLInterStreamCommander commander;
	int nRet = commander.ExecuteCommandFile(L"intercommands.txt");
	ML_ON_FAILED_RETURN(nRet);
	return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
	// testLinearRegress();
	// testAutoRegress();
	testInterStreamAnalysis();
	system("pause");
	return 0;
}


